/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package certificate.model;

import certificate.entity.Course;
import java.util.List;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author MinhCanh99
 */
public class CourseModel extends AbstractTableModel {

    private List<Course> lstCourse = null;
    private String[] columnName = {"IdCourse", "Name", "Price", "TimeAlong"};
    private Class[] colType = {String.class, String.class, Float.class, String.class};
    
    public CourseModel() {
    }

    public CourseModel(List<Course> lstCourse) {
        this.lstCourse = lstCourse;
    }

    @Override
    public int getRowCount() {
        return lstCourse.size();
    }

    @Override
    public int getColumnCount() {
        return columnName.length;
    }

    @Override
    public Class<?> getColumnClass(int columnIndex) {
        return colType[columnIndex];
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        switch (columnIndex) {
            case 0:
                return lstCourse.get(rowIndex).getIdCourse();
            case 1:
                return lstCourse.get(rowIndex).getName();
            case 2:
                return lstCourse.get(rowIndex).getPrice();
            case 3:
                return lstCourse.get(rowIndex).getTimeAlong();
            default:
                return null;
        }
    }

    @Override
    public String getColumnName(int column) {
        return columnName[column];
    }
    
    
}
